[๐ ์ฌ์ดํด2 - ๋ฏธ์ (๋ธ๋์ญ ๊ฒ์ ์คํ)] ์๋ด ๋ฏธ์ ์ ์ถํฉ๋๋ค.#1111
[๐ ์ฌ์ดํด2 - ๋ฏธ์
(๋ธ๋์ญ ๊ฒ์ ์คํ)] ์๋ด ๋ฏธ์
์ ์ถํฉ๋๋ค.#1111RealTake wants to merge 52 commits intowoowacourse:realtakefrom
Conversation
- Deck.cardsํ๋๋ฅผ Set์ผ๋ก ์ ํํด์ ์ค๋ณต์ ๋ํ ๋ฌธ์ ๋ฐฉ์ง - Deck.draw() ์์ finally ๋ฌธ์ ์ฌ์ฉํ๋ ๋์ ์ฝ๋ ํ๋ฆ์ผ๋ก ๊ฐ์
fix: hit&Stand ๋ก์ง ์ค๋ฅ ์์
- DefaultBlackjackRule: judge๋ฅผ Participant ๊ธฐ๋ฐ์ผ๋ก ๋ณ๊ฒฝ, BLACKJACK ๊ฒฐ๊ณผ ์ถ๊ฐ - ๊ฐ ํ๋ ์ด์ด ๋ณ ๋ฐฐํ ๊ธ์ก ์ ๋ ฅ ๋ฐ์
Gyuchool
left a comment
There was a problem hiding this comment.
์๋
ํ์ธ์ ์๋ด
์ฌ์ดํด2 ๋ฏธ์
์งํํ์๋๋ผ ๊ณ ์ํ์
จ์ต๋๋ค!! ์ ๊ตฌํํด์ฃผ์
จ๋ค์๐
๋ช ๊ฐ์ง ์ฝ๋ฉํธ๋ฅผ ๋จ๊ฒจ๋์์ผ๋ ๋ฐ์ ๋ฐ ์๊ฒฌ ์ฃผ์๋ฉด ์ข์ ๊ฒ ๊ฐ์ต๋๋ค.๐
๊ถ๊ธํ ์ ์ DM์ด๋ PR ์ปค๋ฉํธ๋ก ์ธ์ ๋ ์ง ์ฌ์ญค๋ด์ฃผ์ธ์!
- BlackjackGame์ด Players.getPlayerList()๋ก ์ปฌ๋ ์ ์ ๊ฐ์ ธ์ ์ํํ๋ฉด์ ์์ต์ ๊ณ์ฐํ๋ ๋ฐฉ์
- Players ๋ด๋ถ์ ์์ต ๊ณ์ฐ ๋ฉ์๋๋ฅผ ๋๊ณ BlackjackGame์์๋ ํด๋น ๋ฉ์๋๋ฅผ ํธ์ถ๋ง ํ๋ ๋ฐฉ์
๋ ๊ฐ์ง ๊ตฌ์กฐ ์ค ์ผ๊ธ ์ปฌ๋ ์ ์ ์๋์ ๋๋ฉ์ธ ์ฑ ์ ๋ถ๋ฆฌ ์ธก๋ฉด์์ ์ด๋ค ๊ตฌ์กฐ๊ฐ ๋ ์ ์ ํ ์ง ๊ธฐ๋ก ์ ์๊ฒฌ์ ๋ฃ๊ณ ์ถ์ต๋๋ค!
blackJackGame์ ์นด๋ ๊ฒ์ ์งํ์ ๋ค๋ฃจ๊ณ ์๊ธฐ์ ์์ต ๊ณ์ฐ์ ๋ํ ์ฑ ์์ ๋ค๋ฅธ ๊ฐ์ฒด์ ๋งก๊ฒจ๋ณด๋๊ฑด ์ด๋จ๊น์? ๋ฆฌ๋ทฐ ๋ฐ์ํ๋ฉด์ ์ด๋ค ๊ฐ์ฒด๊ฐ ๋ค๋ค์ผํ ์ง ํจ๊ป ๊ฐ์ ํด๊ฐ๋ณด์์ฃ ..!
Service์ ์ญํ ์ด DTO ๋ณํ๊ณผ blackjackGame.xxx() ํ ๋ฒ๋ง ํธ์ถํ๋ ๋จ์ ์์์ด๋ผ, ์ฒ์๋ถํฐ ์๋น์ค ๋ ์ด์ด๋ฅผ ๋์ง ๋ง์์ด์ผ ํ๋ ์ถ์ต๋๋ค.
- ์ง๊ธ ๊ตฌ์กฐ๋ฅผ ์ ์งํ ์ฑ โService = ์ง์ ์ + DTOโ ์ญํ ๋ง ๋ช ์ํ ์ง
- Service ๋ ์ด์ด๋ฅผ ์ ๊ฑฐํ๊ณ Controller๊ฐ Game์ ์ง์ ์ธ์ง
๋ฆฌ๋ทฐ์๋ ๋จ๊ฒผ๋๋ฐ ์ ๋ ๋ชจํธํ๋ค๊ณ ๋๋ผ๊ณ ์์ด์๐ ์๋ด์ ์ฒ์ ์ค๊ณํ ๋ service blackjackGame์ ๊ฐ๊ฐ ์ด๋ค ์ญํ ๋ก ํ์ฉํ๋ ค๊ณ service๋ฅผ ์ถ๊ฐํ์์๊น์?
| } | ||
|
|
||
| private boolean hasDuplicatedName(List<String> playerNames) { | ||
| return playerNames.size() != playerNames.stream().distinct().count(); |
There was a problem hiding this comment.
์ค๋ณต ํ์ธ์ ์ํด ์๋ฃ๊ตฌ์กฐ๋ฅผ ํ์ฉํด๋ณด๋ฉด ์ด๋จ๊น์?
| final List<Player> players = playerNames.stream() | ||
| .map(Player::new) | ||
| .toList(); |
There was a problem hiding this comment.
player๊ฐ์ฒด ์์ฑ ์ฑ ์์ BlackjacService๋ณด๋ค Players์๊ฒ ๋๊ธฐ๋๊ฑด ์ด๋ ์ค๊น์?
There was a problem hiding this comment.
๋๋ฌ๋ ๋ง์ฐฌ๊ฐ์ง๋ก ์ ์ ํ ๊ณณ์์ ๊ฐ์ฒด ์์ฑํ๋ฉด ์ข์ ๊ฒ ๊ฐ๋ค์:)
| private int readPlayerBattingMoneyRetry(String playerName) { | ||
| int battingMoney = -1; | ||
|
|
||
| while (battingMoney <= 0) { | ||
| battingMoney = readPlayerBattingMoney(playerName); | ||
| } | ||
| return battingMoney; | ||
| } |
There was a problem hiding this comment.
do-while๋ฌธ์ ํ์ฉํ๋ฉด ์ด๋จ๊น์? ์ง๊ธ์ -1์ ์๋ฏธ๋ฅผ ํด์ํ๊ธฐ ์ด๋ ต๋ค์..!
There was a problem hiding this comment.
do-while ๋ฌธ ๋ณด๋ค ์ง๊ธ ํํ๊ฐ ๊ฐ๋จํด ๋ณด์ฌ์ ์ ์ฉํ์์ต๋๋ค.
๋ง์์ฃผ์ ๋๋ก -1์ด ํด์ํ๋๋ฐ ๋ถํธํจ์ ์ฃผ๋๊ฒ ๊ฐ์๋ณด์
๋๋ค.! ํผ๋๋ฐฑ ์ฃผ์ ๋๋ก ์์ ํด๋ณด๊ฒ ์ต๋๋ค
| import team.blackjack.view.OutputView; | ||
|
|
||
| public class BlackJackController { | ||
| private final BlackJackService blackJackService; |
There was a problem hiding this comment.
์๋ด์ด ์๊ฐํ์๊ธฐ์ blackJackController์ blackJackService์ ๊ฐ๊ฐ ์ญํ ์ด ๋ฌด์์ผ๊น์?
ํ์ฌ๋ ๋ก์ง์ด Controller์ ๋ ๋ง์ ๊ฒ ๊ฐ์๋ฐ ์ด๋ป๊ฒ ์๊ฐํ์ค๊น์?
| OutputView.printAskDrawCard(playerName); | ||
| String hitYn = InputView.readHitDecision(); | ||
|
|
||
| while (!"y".equalsIgnoreCase(hitYn) && !"n".equalsIgnoreCase(hitYn)) { |
There was a problem hiding this comment.
"y","n"์ด ๋ฐ๋ณต๋๋ ์์๋ก ๊ด๋ฆฌํ๋๊ฑด ์ด๋ ์ค๊น์?
| public void drawInitialCards() { | ||
| this.players.initPlayerHands(deck); | ||
|
|
||
| this.dealer.hit(dealer.draw(deck)); |
There was a problem hiding this comment.
| this.dealer.hit(dealer.draw(deck)); | |
| this.dealer.hit(deck.draw()); |
์ด๋ ๊ฒ๋ ๊ตฌํํ ์ ์์ ๊ฒ ๊ฐ์๋ฐ dealer.draw()๋ฉ์๋๋ฅผ ๋ง๋ ์ด์ ๊ฐ ์์๊น์?
| private double calculateMoney(Player player) { | ||
| final Result result = judge(player); | ||
| return result.getOdds() * player.getBatMoney(); | ||
| } | ||
|
|
||
| private Result judge(Player player) { | ||
| if (player.isBust()) { |
There was a problem hiding this comment.
์ ์ ๊ณ์ฐ ๋ฐ ํ๋จํ๋ ๋ก์ง์ ์ค์ํ ๋ก์ง์ธ๋ฐ์. ํ ์คํธ๊ฐ ๊ฐ๋ฅํ ๊ตฌ์กฐ๊ฐ ์๋๊ฒ ๊ฐ๋ค์..! ์ ์ ํ ๊ฐ์ฒด์๊ฒ ์ฑ ์์ ๋๊ฒจ๋ณด๋๊ฑด ์ด๋จ๊น์?
|
|
||
| public List<Integer> getScore() { | ||
| return this.number.score; | ||
| public Set<Integer> getScore() { |
| public Dealer dealer; | ||
| public Player pobi; | ||
| public Player jason; | ||
| public Players players; | ||
| public BlackjackGame game; |
| public class Player extends Participant { | ||
| private final String name; | ||
| private final List<Hand> hands; | ||
| private double batMoney; |
There was a problem hiding this comment.
๊ท์น 3: ๋ชจ๋ ์์๊ฐ๊ณผ ๋ฌธ์์ด์ ํฌ์ฅํ๋ค.
๋ฐฐํ
๊ธ์ก์ด ์์๊ฐ ์๋๋๋ก view์์ ์ ๋ง์ผ์
จ์ด์..!๐
๋ค๋ง, ๋ฐฐํ
๊ธ์ก์ด ์์๊ฐ ์๋๋๊ฑด ๋๋ฉ์ธ ๊ท์น์ ํด๋น๋๋ค๊ณ ์๊ฐํ๋๋ฐ ๋๋ฉ์ธ์์๋ ๊ฒ์ฆํ๋๊ฑด ์ด๋ ์ค๊น์?
์๋ ํ์ธ์, ๊ธฐ๋ก !
์ฃผ์ ํผ๋๋ฐฑ์ ์ฌ๋ฌ ๋ฒ ๊ณฑ์น์ด ๋ณด๋ฉด์ ๋ค์ํ ๋ฐฉ์๋ ์๋ํด ๋ณด๋๋ผ PR๊ณผ ๋ต์ฅ์ ๋ฆ๊ฒ ์ฌ๋ฆฌ๊ฒ ๋์ด ์ฃ์กํฉ๋๋คใ ใ
ํผ๋๋ฐฑ์ ๋ฐํ์ผ๋ก ๋ค๋ฅธ ํฌ๋ฃจ๋ถ๋ค๊ณผ๋ ์๊ฒฌ์ ๋๋๊ณ , ์ฌ๋ฌ ํฌ๋ฃจ๋ค์ ์ฝ๋๋ฅผ ์ดํด๋ณด๋ฉด์ ์ ๊ฐ ๋ฏธ์ฒ ์๊ฐํ์ง ๋ชปํ๋ ๋ฐฉ์์ด๋ ํค์๋๋ค์ ๋ง์ด ์๊ฒ ๋์์ต๋๋ค. ๋๋ถ์ ๋ง์ ๊ฒ์ ๋ฐฐ์ฐ๋ ์๊ฐ์ด ๋์๊ณ , ๊ทธ๋ฌ๋ค ๋ณด๋ ์ผ์ฃผ์ผ์ด ์ ๋ง ๋น ๋ฅด๊ฒ ์ง๋๊ฐ ๊ฒ ๊ฐ์ต๋๋ค.
ํนํ ์ค๋๊ธฐ๊ฐ ๊ฐ๋ฐ์ ํด์ค๋ฉด์ ์ฃผ์ ๋ํ ๊ด๋ฆฌ์ ๋์์ด ๋ ์ ์๋ค๋ ์ ์ ์๊ฐํ์ง ๋ชปํ๋ ๋ถ๋ถ์ด๋ผ ์์ง๋ ๋ต..ํฉ๋๋ค..!
PR์ ์์ ๋ค์ ์ข์ ํผ๋๋ฐฑ ์ฃผ์ ์ ๋ค์ ํ ๋ฒ ๊ฐ์ฌ๋๋ฆฝ๋๋ค..!
์ฒดํฌ ๋ฆฌ์คํธ
test๋ฅผ ์คํํ์ ๋, ๋ชจ๋ ํ ์คํธ๊ฐ ์ ์์ ์ผ๋ก ํต๊ณผํ๋์?์ด๋ค ๋ถ๋ถ์ ์ง์คํ์ฌ ๋ฆฌ๋ทฐํด์ผ ํ ๊น์?
์ํฉ
์ฌ์ดํด 2์์ ๋ฐฐํ ๊ธฐ๋ฅ์ด ์ถ๊ฐ๋๋ฉด์ ๊ฐ ์ฐธ๊ฐ์์ ์์ต์ ๊ณ์ฐํด์ผ ํ๋ ์๊ตฌ์ฌํญ์ด ์๊ฒผ์ต๋๋ค.
ํ์ฌ๋ BlackjackGame์ calculateAllPlayerRevenue() ๋ฉ์๋์์ ์ ์ฒด ํ๋ ์ด์ด์ ์์ต์ ๊ณ์ฐํ๊ณ ์์ต๋๋ค.
์ด ๊ณผ์ ์์ Players ๋ด๋ถ์ ํ๋ ์ด์ด๋ค์ ์ํํด์ผ ํ๊ธฐ ๋๋ฌธ์ Players.getPlayerList() ๋ฉ์๋๋ฅผ ๋ง๋ค๊ฒ ๋์์ต๋๋ค.
๊ณ ๋ฏผ
getPlayerList()๋ ๋ด๋ถ ์ปฌ๋ ์ ์ ์ธ๋ถ๋ก ๋ ธ์ถํ๊ฒ ๋๋ฏ๋ก ์ผ๊ธ ์ปฌ๋ ์ ์ ์ทจ์ง์ ๋ค์ ์ด๊ธ๋๋ ๊ฒ์ด ์๋์ง ๊ณ ๋ฏผ์ด ๋์์ต๋๋ค.
๊ทธ๋์ calculateAllPlayerRevenue() ๋ฉ์๋๋ฅผ Players ๋ด๋ถ๋ก ์ด๋์ํค๋ ๊ฒ๋ ํ๋์ ๋ฐฉ๋ฒ์ด๋ผ๊ณ ์๊ฐํ์ต๋๋ค.
๋ง์นจ Player๊ฐ betMoney ํ๋๋ฅผ ๊ฐ์ง๊ณ ์๊ธฐ ๋๋ฌธ์ Players๊ฐ ๊ฐ Player๋ฅผ ์ํํ๋ฉฐ ์์ต์ ๊ณ์ฐํ๋ ๊ตฌ์กฐ๋ ๊ฐ๋ฅํด ๋ณด์ ๋๋ค.
๋ค๋ง ์์ต ๊ณ์ฐ์ด๋ผ๋ ํ์๊ฐ Player๋ Players๋ณด๋ค๋ ๊ฒ์์ ๊ท์น๊ณผ ํ๋ฆ์ ๋ด๋นํ๋ BlackjackGame์์ ์ฒ๋ฆฌํ๋ ๊ฒ์ด ๋ ์์ฐ์ค๋ฌ์ด ๊ฒ์ ์๋์ง ๊ณ ๋ฏผ์ด ๋ฉ๋๋ค.
๋ฆฌ๋ทฐ ์์ฒญ
1. BlackjackGame์ด Players.getPlayerList()๋ก ์ปฌ๋ ์ ์ ๊ฐ์ ธ์ ์ํํ๋ฉด์ ์์ต์ ๊ณ์ฐํ๋ ๋ฐฉ์
2. Players ๋ด๋ถ์ ์์ต ๊ณ์ฐ ๋ฉ์๋๋ฅผ ๋๊ณ BlackjackGame์์๋ ํด๋น ๋ฉ์๋๋ฅผ ํธ์ถ๋ง ํ๋ ๋ฐฉ์
๋ ๊ฐ์ง ๊ตฌ์กฐ ์ค ์ผ๊ธ ์ปฌ๋ ์ ์ ์๋์ ๋๋ฉ์ธ ์ฑ ์ ๋ถ๋ฆฌ ์ธก๋ฉด์์ ์ด๋ค ๊ตฌ์กฐ๊ฐ ๋ ์ ์ ํ ์ง ๊ธฐ๋ก ์ ์๊ฒฌ์ ๋ฃ๊ณ ์ถ์ต๋๋ค!
2. Service์ Game์ ์ญํ ๊ฒฝ๊ณ
์ํฉ
-> getter๋ฅผ ์ ๊ฑฐํ๋ ๋์ ์๋น์ค๊ฐ ์ ๊ฒํฐ๋ฅผ ์ฌ์ฉํด์ ์ฐ๊ฒ ๋๋์ง๋ฅผ ๋ณด๊ณ , ๊ทธ ์ด์ ๋ฅผ ๋ค์ game์์ ํ๋๋ก ํ๋ค๋ณด๋, ๋๋ถ๋ถ์ ์๋น์ค ๋ก์ง๋ค์ด Game์ผ๋ก ์ด๋ํ๊ฒ ๋์์ต๋๋ค. ์ง๊ธ์ Game์ด ๊ฒ์ ์งํ ๋ก์งโ์, Service๊ฐ โGame ์์ฑ + Game ์์ + DTO ๋ณํโ์ ๋งก๊ณ ์์ต๋๋ค.
ํ์ฌ ์๋น์ค ํด๋์ค์ ์ญํ ์ ๋๋ฉ์ธ์ ์ง์ ์ปจํธ๋กค๋ฌ์ ๋ฐํ ํ๊ธฐ ๋ณด๋จ DTO๋ฅผ ๋ณํํด์ ์ฃผ๋๋ฐ ์๋ฏธ๋ฅผ ๋๊ณ ์์ต๋๋ค.
๊ณ ๋ฏผ
Service์ ์ญํ ์ด DTO ๋ณํ๊ณผ blackjackGame.xxx() ํ ๋ฒ๋ง ํธ์ถํ๋ ๋จ์ ์์์ด๋ผ, ์ฒ์๋ถํฐ ์๋น์ค ๋ ์ด์ด๋ฅผ ๋์ง ๋ง์์ด์ผ ํ๋ ์ถ์ต๋๋ค.
๋ฆฌ๋ทฐ ์์ฒญ
๊ธฐ๋ก ์ ์๊ฒฌ์ ๋ฃ๊ณ ์ถ์ต๋๋ค.!
์๊ฐ ๋ด์ด ๋ฆฌ๋ทฐํด ์ฃผ์ ์ ๋ค์ ํ ๋ฒ ๊ฐ์ฌ๋๋ฆฝ๋๋ค..!